package com.example.cet4try.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.cet4try.R;
import com.example.cet4try.adapter.PageListAdapter;

public class ActivityAdmin extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_admin);

        ListView ls_admin = findViewById(R.id.ls_admin);
        final String[] db_list = new String[]{"用户数据","反馈数据","四级单词数据","六级单词数据","考研单词数据"};
        PageListAdapter setting = new PageListAdapter(db_list,ActivityAdmin.this);
        ls_admin.setAdapter(setting);
        ls_admin.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent(ActivityAdmin.this,ActivityDatabaseManager.class);
                switch (i){
                    case 0:
                        intent.putExtra("type","user");
                        break;
                    case 1:
                        intent.putExtra("type","feedback");
                        break;
                    case 2:
                        intent.putExtra("type","cet4");
                        break;
                    case 3:
                        intent.putExtra("type","cet6");
                        break;
                    case 4:
                        intent.putExtra("type","unge");
                        break;
                    default: intent = null;
                }
                if (intent != null){
                    intent.putExtra("dbname",db_list[i]);
                    startActivity(intent);
                }

            }
        });


    }
}
